import { Component, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';

import { takeUntil } from 'rxjs/operators'

import { AuthenticationService } from '../../core/services/authentication.service';
import { BaseDirective } from '../../core/models/base-directive.model';
import { User } from '../../users-demo/shared/user.model';

@Component({
    selector: 'op-lock-screen',
    templateUrl: './lock-screen.component.html'
})
export class LockScreenComponent extends BaseDirective implements OnInit {
    user: User;

    constructor(
        private authenticationService: AuthenticationService,
        private router: Router
    ) {
        super();
    }

    ngOnInit(): void {
        super.ngOnInit();

        this.authenticationService.currentUser$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(p => this.user = p);
    }

    unlockScreen(): void {
        this.authenticationService.unlockScreen();
    }
}